#ifndef __EVENT_LOOP_H
#define __EVENT_LOOP_H

#include <vector>
#include "epoller.h"
#include "handler.h"

class TCPServer;

class EventLoop: public EPoller
{
public:
    EventLoop();
    ~EventLoop();

    ///
    /// \brief EventLoop::runLoop
    /// \details IO多路复用epoll，一般作为主线程使用
    void runLoop();

    int setNonBlocking(int fd);
    bool registerServerEvent(int fd, HandlePtr handler);
    bool registerSocketEvent(int fd, HandlePtr handler);

private:
    std::vector<int> m_listenList;
    bool isListenFD(int fd);

    //事件处理函数
    HandlerMap m_handerMap;
    void handleEvents(int size);
};

#endif // __EVENT_LOOP_H
